package com.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/*
过滤器
    过滤所有的请求,没有登录的请求都要过滤掉

 */
public class LoginFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest req= (HttpServletRequest) servletRequest;
        System.out.println("大S小蛮腰");
//        放行  针对性放行
//        那些请求需要登录了才放学,那些请求无需登录就要放心
//        需要登录只要才能放行
//        filterChain.doFilter(servletRequest,servletResponse);
        String sv = req.getServletPath();
        if ("/zhuce".equals(sv)||"/register.jsp".equals(sv)
                ||"/denglu".equals(sv)||"/dl.jsp".equals(sv)){
//            放行
            filterChain.doFilter(servletRequest, servletResponse);
            return;
        }
    }
}
